package weibo

import (
	"github.com/crozz-net/gopenapi/request"
	"github.com/crozz-net/gopenapi/weibo/model/short_url/share"
	"net/url"
)

type api_short_url_share struct {
	client_id string
}

/**
 * 获取短链接在微博上的微博分享数<br/>
 * http://open.weibo.com/wiki/2/short_url/share/counts
 *
 * @param url_short 需要取得分享数的短链接，需要URLencoded，最多不超过20个
 */
func (this *api_short_url_share) Counts(source, access_token string, url_short []string) (*share.Resp_counts, error) {
	param := url.Values{}
	param.Add("source", source)
	param.Add("access_token", access_token)
	for _, v := range url_short {
		param.Add("url_short", v)
	}

	obj := &share.Resp_counts{}
	err := request.HttpGetAsObj(BASE_URL+"short_url/share/counts.json", param, obj)

	return obj, err
}

func (this *api_short_url_share) Statuses(source, access_token, since_id, max_id, count, page string, url_short []string) (*share.Resp_statuses, error) {
	param := url.Values{}
	param.Add("source", source)
	param.Add("access_token", access_token)
	param.Add("since_id", since_id)
	param.Add("max_id", max_id)
	param.Add("count", count)
	param.Add("page", page)
	for _, v := range url_short {
		param.Add("url_short", v)
	}

	obj := &share.Resp_statuses{}
	err := request.HttpGetAsObj(BASE_URL+"short_url/share/statuses.json", param, obj)

	return obj, err
}
